import React, { Component, PropTypes } from 'react';
import { Utility } from 'components';
import { connect } from 'react-redux';
import * as CommonActions from 'redux/modules/reduxCommon';
const styles = require('./scss/MeetingAdd.scss');

@connect(
  state => ({
    Title: state.Common.Title,                                          // 标题
    UrlParams: state.Common.UrlParams,                                  // URL参数
  }),
  { ...CommonActions })
export default class MeetingAdd extends Component {
  static propTypes = {
    Title: PropTypes.string,                                              // 标题
    UrlParams: PropTypes.object,                                          // url 参数
  };

  constructor(props) {
    super(props);

    this.state = { RefreshComplete: true, NextDataComplete: true };
    this.state.ScrollData = [];
  }

  componentDidMount() {
    const { } = Utility;
    this.state.IsMount = true;
  }

  componentWillUnmount() {
    delete this.state.IsMount;
  }

  /**
   * 更新渲染
   */
  __UpdateRender() {
    if (!!this.state.IsMount) {
      this.setState({ __CurrentTempDate: new Date().getTime() });
    }
  }

  __HandlerCancel() {
    Utility.$goBack();
  }

  __HandlerSubmit() {
    const { txtContent } = this.refs;
    const __value = txtContent.value;
    const __valueArray = __value.split('\n');
    console.log(__value);

    const __TaskList = [];

    __valueArray.forEach((key) => {
      console.log(key);
      if (key && key !== '') {
        __TaskList.push(key);
      }
    });

    const __html = (
      <div className={styles.taskList}>
        {
          __TaskList.map((task, index) => {
            return (<div key={index} className={styles.task}>
              <div className={styles.no}>{index + 1}、</div>
              <div className={styles.content}>{task}</div>
            </div>);
          })
        }
      </div>
    );
    Utility.$showDialog(__html, '任务列表', () => {
      console.log(__TaskList);
    }, () => { });
  }

  render() {
    const { } = this.state;
    return (
      <div className={styles.meetingAddCss}>
        <div className={styles.txtContent}>
          <textarea ref="txtContent"></textarea>
        </div>
        <div className={styles.btns}>
          <div className={styles.ok} onClick={this.__HandlerSubmit.bind(this)}>确定</div>
          <div className={styles.cancel} onClick={this.__HandlerCancel.bind(this)}>取消</div>
        </div>
      </div>
    );
  }
}

